package com.wjyf.reducing_bento.controller;


import com.wjyf.reducing_bento.common.BaseResponse;
import com.wjyf.reducing_bento.common.ResultUtils;
import com.wjyf.reducing_bento.service.CouponReceiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 优惠券领取记录表 前端控制器
 * </p>
 *
 * @author wjyf
 * @since 2023-03-14 08:36:33
 */
@RestController
@RequestMapping("/coupon-receive-bean")
@Api(tags = "领取优惠卷")
public class CouponReceiveController {

    @Resource
    private CouponReceiveService couponReceiveService;

    @PostMapping("receive/{couponId}")
    @ApiOperation("领取优惠卷")
    public BaseResponse receive(@PathVariable @ApiParam("优惠卷id") Integer couponId, HttpServletRequest request){
        boolean isSuccess = couponReceiveService.receive(couponId, request);
        return ResultUtils.success(isSuccess);
    }
}
